#pragma once


class CGameState :
	public CBaseState,
	public CCharacterAckMsgHandler,
	public CMapAreaAckMsgHandler
{
protected:
	CBLZWOWSceneLoader				m_SceneLoader;
	CD3DLight *						m_pLight;
	CMainCamera *					m_pCamera;
	CD3DCamera *					m_pBackGroundCamera;

	UINT							m_CurMapID;

	bool							m_KeyPressInfo[DIR_KEY_MAX];
	bool							m_IsRotation;
	int								m_StartX,m_StartY;

	CCharacter *					m_pPlayer;
	CEasyMap<UINT64,CCharacter*>	m_CharPool;

	bool							m_IsInMapLoading;
	


	DECLARE_DOS_MSG_MAP_CLIENT(CGameState)
public:
	CGameState(CMainFrame * pMainFrame);
	~CGameState(void);

	virtual bool Init();
	virtual void Destory();
	virtual int Update(float Time);
	virtual bool OnWMSG(MSG* pMsg);

	bool GetSceneHeight(CD3DVector3 Pos,float& Height);
	bool IsLineIntersect(CD3DVector3 StartPos,CD3DVector3 EndPos);
	void SynPlayerPos(FLOAT PosX,FLOAT PosY,FLOAT Height);

protected:
	void ParseDirKey(int DirKeyChange);
	CCharacter * AddChar(UINT64 CharID,CSmartStruct& CharData);
	bool DeleteChar(UINT64 CharID);
	CCharacter * FindChar(UINT64 CharID);

protected:

	virtual int QueryCharInfoAck(int Result ,CSmartStruct& CharData );
	virtual int QueryMoveAck(int Result );	
	virtual int QueryFlyAck(int Result );
	virtual int MapChange(UINT MapID ,float PosX ,float PosY ,float Direction );
	virtual int QueryJumpAck(UINT64 ObjectID ,int Result );

	virtual int NewMapObject(UINT64 ObjectID ,CSmartStruct& MoveStatus );
	virtual int DeleteMapObject(UINT64 ObjectID );
	virtual int MoveStatusUpdate(UINT64 ObjectID ,BYTE IsForce ,CSmartStruct& MoveStatus );
	virtual int EventMsgPacket(CSmartStruct& EventMsg );
};
